import React, { Component } from 'react'

class Son extends Component {
    render() {
        return (
            <div>
                <h2>{this.props.fatherToSon}</h2>
                <button onClick={() => {
                    // 触发调用父组件方法
                    this.props.sonToFather()
                }}>click</button>
            </div>
        )
    }
}

export default class App extends Component {
    state = {
        data: "父传子的数组",
        msg: "初始值"
    }
    render() {
        return (
            <div>
                <div>{this.state.msg}</div>
                <Son fatherToSon={this.state.data} sonToFather={() => { this.change() }} />
            </div>
        )
    }

    change() {
        console.log("子传父调用");
        this.setState({
            msg: "子传父调用"
        })
    }
}
